home *** CD-ROM | disk | FTP | other *** search
- /* TrackUpdate.c */
- /*
- * Copyright © 1989 Martin Minow. All rights reserved.
- *
- * Update the track data. User programs call TrackUpdate,
- * internally, _Track_do_update is called.
- *
- * void
- * TrackUpdate(rectp, track_handle)
- * Rect *rectp;
- * TrackHandle track_handle;
- *
- * void
- * _Track_do_update(tr, rectp)
- * TrackPtr tr;
- * Rect *rectp;
- */
-
- #include "TrackEdit.h"
- #define TR (*tr)
-
- static void drawtext(TrackPtr, Rect *);
-
- void
- TrackUpdate(update_rect_ptr, track_handle)
- Rect *update_rect_ptr;
- TrackHandle track_handle;
- {
- register TrackPtr tr;
- _Track_state state;
-
- tr = _Track_lock(track_handle, &state);
- _Track_do_update(tr, update_rect_ptr);
- _Track_unlock(&state);
- }
-
- void
- _Track_do_update(tr, update_rect_ptr)
- register TrackPtr tr;
- Rect *update_rect_ptr;
- {
- RgnHandle clip;
- Rect view;
-
- /*
- * Get a copy of the current grafPort's clipping
- * region (TrackLock has already clipped the window
- * to the TrackRecord's viewRect) and intersect that
- * with the update_rect. Don't bother restoring
- * the clipRgn: TrackUnlock will do that.
- */
- clip = NewRgn();
- RectRgn(clip, update_rect_ptr);
- SectRgn(clip, thePort->clipRgn, thePort->clipRgn);
- /*
- * Draw any text inside the update rectangle, then.
- * if the window is active, invert any hilited text.
- */
- drawtext(tr, update_rect_ptr);
- if (_Track_is_set(tr, _Track_is_active)) {
- _Track_hilite(tr, TR.selStart, TR.selEnd);
- if (_Track_is_set(tr, _Track_caret_visible))
- _Track_invert_caret(tr);
- }
- DisposeRgn(clip);
- }
-
- /*
- * draw_text(track_ptr, draw_rect)
- * Draw text onto the screen. The caller has set
- * the grafPort's clip rect. The draw_rect defines
- * the top and bottom of the data to be drawn.
- */
- static void
- drawtext(tr, view)
- register TrackPtr tr;
- Rect *view;
- {
- register int vpixel;
- register long first, last;
- register int t_width, w_width;
- register int hpixel;
-
- /*
- * Locate the first and last rows to be drawn.
- * Note that we may have a partial last line,
- * so we try to draw one extra.
- */
- first = _Track_pixel_row(tr, view->top);
- last = _Track_pixel_row(tr, view->bottom) + 1;
- if (last >= TR.nLines)
- last = TR.nLines;
- /*
- * Since the view rectange we are presented may not
- * be aligned with our line grid, we compute our
- * pen position so it's aligned with the top row.
- */
- vpixel = _Track_row_pixel(tr, first);
- MoveHHi(TR.hText);
- HLock(TR.hText);
- while (first < last) {
- if (first >= 0) {
- MoveTo(
- (INTEGER) _Track_h_origin(tr, first),
- vpixel
- );
- DrawText(
- *TR.hText,
- TR.lineStarts[first],
- TR.lineStarts[first + 1] - TR.lineStarts[first]
- );
- }
- vpixel += TR.lineHeight;
- first++;
- }
- HUnlock(TR.hText);
- }
-
-